{% extends "base.html" %}

{% block body %}

<ol class="breadcrumb">
  <li>Ops Manage</li>
  <li class="active">File Manager</li>
</ol>

<div class="page-header">
    <h2>
        File Manager
    </h2>
</div>

<table class="table table-hover">
    <caption>
      <form class="form-inline" style="float: right;" action="/filemanager/directory_list" method="post">
       {% csrf_token %}
        <div class="form-group">
          <p class="form-control-static">
              <select class="form-control" name="filter_select">
                <option>Name</option>
                <option>Size</option>
                <option>Mtime</option>
              </select>
          </p>
          <input type="text" class="form-control" name="filter_keyword" value="{{filter_keyword}}" placeholder="">
          <input type="hidden" class="form-control" name="dist" value="{{current_directory}}" placeholder="">
        </div>
        <button type="submit" class="btn btn-default"><span class="fa fa-filter"></span> Filter</button>
        <div class="btn-group">
        <button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
          More Actions <span class="caret"></span>
        </button>
        <ul class="dropdown-menu dropdown-menu-right">
          <li><a href="#">Download</a></li>
          <li><a href="#">Download</a></li>
          <li role="separator" class="divider"></li>
          <li><a href="#">Other</a></li>
        </ul>
      </div>
      </form>
    </caption>
    <tr>
        <td colspan="12" data-column="0">
            <span class="table_count">Displaying {{ file_list_count }} items <code style="font-size: 13px;">Path: {{path}}</span>
        </td>
    </tr>
    <tr class="active">
        <th><input type="checkbox" name="check_all" id="check_all" onclick="checkAll()"></th>
        <th width="40%">Name</th>
        <th width="20%">Size</thw>
        <th width="25%">Mtime</th>
        <th colspan="4" width="15%">Actions</th>
    </tr>
    {% for file_info in file_list %}
    {% if file_info.is_directory == 1  %}
    <tr>
        <td><input type="checkbox" name="check_item"></td>
        <td>
        <span class="fa fa-folder-o">
            {% if file_info.file_name != '..' %}
            <a style="color:inherit;" href="?host={{host}}&path={{path}}/{{file_info.file_name}}">
            {% endif %}
            {% if file_info.file_name == '..' %}
            <a style="color:inherit;" href="?host={{host}}&path={{parent_path}}">
            {% endif %}
            {{file_info.file_name}}
            </a>
        </span>
        </td>
        <td>{{file_info.file_size}}</td>
        <td>{{file_info.file_mtime}}</td>
        <td>

          <!-- Split button -->
          {% if file_info.file_name != '..' %}
          <div class="btn-group">
            <a type="button" class="btn btn-default btn-sm" href="?host={{host}}&path={{path}}/{{file_info.file_name}}">Open</a>
            <button type="button" class="btn btn-default btn-sm dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
              <span class="caret"></span>
            </button>
            <ul class="dropdown-menu dropdown-menu-right">
              <li><a href="">Download Zip</a></li>
            </ul>
          </div>
          {% endif %}
          {% if file_info.file_name == '..' %}
          <div class="btn-group">
            <a type="button" class="btn btn-default btn-sm" href="?host={{host}}&path={{parent_path}}">Open</a>
            <button type="button" class="btn btn-default btn-sm dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
              <span class="caret"></span>
            </button>
            <ul class="dropdown-menu dropdown-menu-right">
              <li><a href="">Download Zip</a></li>
            </ul>
          </div>
          {% endif %}        
        </td>
    </tr>
    {% endif %}
    {% endfor %}

    {% for file_info in file_list %}
    {% if file_info.is_directory == 0  %}
    <tr>
        <td><input type="checkbox" name="check_item"></td>
        <td>
        <span class="fa fa-file-text-o">
            <a a style="color:inherit;" href="/filemanager/text_viewer?host={{host}}&path={{path}}/{{file_info.file_name}}">
            {{file_info.file_name}}
            </a>
        </span>
        </td>
        <td>{{file_info.file_size}}</td>
        <td>{{file_info.file_mtime}}</td>
        <td>

        <!-- Split button -->
          <div class="btn-group">
            <a type="button" class="btn btn-default btn-sm" href="/filemanager/text_viewer?host={{host}}&path={{path}}/{{file_info.file_name}}">Tail &nbsp;&nbsp;</a>
            <button type="button" class="btn btn-default btn-sm dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
              <span class="caret"></span>
            </button>
            <ul class="dropdown-menu dropdown-menu-right">
              <li><a href="/filemanager/file_download?host={{host}}&path={{path}}/{{file_info.file_name}}">Download</a></li>
            </ul>
          </div>
        </td>
    </tr>
    {% endif %}
    {% endfor %}
    <tr>
        <td colspan="12" data-column="0">
            <span class="table_count">Displaying {{ file_list_count }} items</span>
        </td>
    </tr>
</table>

{% endblock %}